package zli.prototype.singleton;

import lombok.Data;

import java.util.List;

/**
 * @Desc
 * @Author Zerlinda
 * @Date 2022/5/9 10:30
 * @Version 1.0
 * 单例模式遇到原型模式
 * 单例模式和原型模式天生不共存
 */
@Data
public class ConcretePrototype implements Cloneable {

    private int age;
    private String name;
    private List<String> hobbies; // 引用类型，Cloneable的clone方法赋值的是引用类型的地址

    private static ConcretePrototype instance = new ConcretePrototype();

    private ConcretePrototype() {}

    public static ConcretePrototype getInstance() {
        return instance;
    }

    @Override
    public ConcretePrototype clone() {
        return instance;
    }


}
